package sumBase;

public class Solution {
    public int sumBase(int n, int k) {
        return sum(baseK(n,k));
    }
    private int baseK(int n,int k){
        int res=0;
        int i=0;
        while(n>0){
            res+=Math.pow(10,i)*(n%k);
            n/=k;
            i++;
        }
        return res;
    }
    private int sum(int n){
        int sum=0;
        while(n>0){
            sum+=n%10;
            n/=10;
        }
        return sum;
    }
}
